How To Connect to another Database inside a plpgsql function

How To Connect to another Database inside a plpgsql function

am 13.02.2004 09:56:55 von gezeala25

--0-1584588277-1076662615=:67415
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by zippy.ims.net id i1D8wG818632

Hi Guys!
=20
I have 2 database namely "DB1" and "DB2".
=20
In DB1 I created a plgpsql function fnTest().
=20
My problem is inside fnTest() I need to check some tables in DB2! I've no=
idea how to do this. Usually when I make a function I only access tables=
/views/functions in the same database. I really don't know if this is pos=
sible.
=20
BTW, I googled my problem but did not see any topics on this.
=20
Need your expertise on this one guys...TIA!



Marie Gezeala M. Bacu=F1o II=20
IS Department
Muramoto Audio-Visual Phils., Inc.
MEPZ1, Lapu-Lapu City, Cebu, Philippines 6015


The person with the ultimate cachinnation possesses, thereby, the optimal=
cachinnation.




---------------------------------
Yahoo! Messenger - Communicate instantly..."Ping" your friends today! D=
ownload Messenger Now
--0-1584588277-1076662615=:67415
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by zippy.ims.net id i1D8wG818632

Hi Guys!

 

I have 2 database namely "DB1" and "DB2".

 

In DB1 I created a plgpsql function fnTest().

 

My problem is inside fnTest() I need to check some ta=
bles in DB2! I've no idea how to do this. Usually when I make a func=
tion I only access tables/views/functions in the same database. I re=
ally don't know if this is possible.

 

BTW, I googled my problem but did not see any topics on this.

 

Need your expertise on this one guys...TIA!



Mari=
e Gezeala M. Bacu=F1o II
R>
IS Department
Muramoto Audio-=
Visual Phils., Inc.
MEPZ1, Lapu-Lapu City, Cebu, Philippines 6015
<=
/STRONG>


The person with =
the ultimate cachinnation possesses, thereby, the optimal cachinnation. R>

size=3D1> com/mail/tagline_messenger/*http://uk.messenger.yahoo.com">=20
Yahoo! Messenger
- Communicate instantly..."Ping" your friends=20
today! k.messenger.yahoo.com/download/index.html">Download Messenger Now=

--0-1584588277-1076662615=:67415--

Re: How To Connect to another Database inside a plpgsql function

am 13.02.2004 10:30:55 von Mark Gibson

Gezeala 'Eyah' Bacu=F1o II wrote:

> Hi Guys!
> =20
> I have 2 database namely "DB1" and "DB2".
> =20
> In DB1 I created a plgpsql function fnTest().
> =20
> My problem is inside fnTest() I need to check some tables in DB2! I've=20
> no idea how to do this. Usually when I make a function I only access=20
> tables/views/functions in the same database. I really don't know if=20
> this is possible.
> =20

Take a look at contrib/dblink, it allows cross database queries like this=
:

SELECT *
FROM
dblink('host=3Dmyhost dbname=3DDB1 user=3Dme',
'SELECT col1, col2, col3
FROM mytable')
AS t (col1 integer, col2 text, col3 real);

--=20
Mark Gibson
Web Developer & Database Admin
Cromwell Tools Ltd.
Leicester, England.


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Re: How To Connect to another Database inside a plpgsql function

am 16.02.2004 02:50:54 von gezeala25

--0-639861131-1076896254=:61514
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by hosting.commandprompt.com id i1G1soL24525

Sir, I would really appreciate it if you can please expound more on how t=
o issue a "connect" inside a plpgsql function??
=20
Daghang Salamat sa iyong prompt reply..
=20
I apologize for the late reply kase wala kaming work last saturday.

BTW, I'm not that good in bisaya that's why combination ng bisaya, tagalo=
g and english ang reply ko ;)

Manuel Cabido wrote:
Hi Eyah,

Try daw ug issue ug "connect" to db2 within your procedure in db1.

Manny




Marie Gezeala M. Bacu=F1o II=20
IS Department
Muramoto Audio-Visual Phils., Inc.
MEPZ1, Lapu-Lapu City, Cebu, Philippines 6015


The person with the ultimate cachinnation possesses, thereby, the optimal=
cachinnation.




---------------------------------
Yahoo! Messenger - Communicate instantly..."Ping" your friends today! D=
ownload Messenger Now
--0-639861131-1076896254=:61514
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by hosting.commandprompt.com id i1G1soL24525

Sir, I would really appreciate it if you can please expound more on =
how to issue a "connect" inside a plpgsql function??

 

Daghang Salamat sa iyong prompt reply..

 

I apologize for the late reply kase wala kaming work last saturday.<=
/DIV>

BTW, I'm not that good in bisaya that's why combination ng bisay=
a, tagalog and english ang reply ko ;)


Manuel Cabido <manny@tinago.msuiit.edu.ph> w=
rote:

BORDER-LEFT: #1010ff 2px solid">Hi Eyah,

Try daw ug issue ug "conn=
ect" to db2 within your procedure in db1.

Manny

E>


Mari=
e Gezeala M. Bacu=F1o II
R>
IS Department
Muramoto Audio-=
Visual Phils., Inc.
MEPZ1, Lapu-Lapu City, Cebu, Philippines 6015
<=
/STRONG>


The person with =
the ultimate cachinnation possesses, thereby, the optimal cachinnation. R>

size=3D1> com/mail/tagline_messenger/*http://uk.messenger.yahoo.com">=20
Yahoo! Messenger
- Communicate instantly..."Ping" your friends=20
today! k.messenger.yahoo.com/download/index.html">Download Messenger Now=

--0-639861131-1076896254=:61514--